var t = getApp();

Page({
    data: {
        language: "",
        store_id: "",
        inpvalue: "",
        page: 1,
        goods_data: ""
    },
    onLoad: function(t) {
        this.setData({
            store_id: t.store_id,
            show_num: t.show_num
        }), this.getStoreInfo();
    },
    inpbtn: function(t) {
        console.log(t.detail.value), this.setData({
            inpvalue: t.detail.value
        });
    },
    rentAllSelectHandle: function(t) {
        console.log(t), this.setData({
            result: t.detail
        });
    },
    btntap: function() {
        console.log(this.data.result);
        var t = {
            store_id: this.data.store_id,
            choose_goods: this.data.result
        };
        this.tapPush(t);
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.current_page <= this.data.last_page) wx.showToast({
            title: "没有更多",
            icon: "none",
            duration: 1500
        }); else if (this.data.current_page > this.data.last_page) {
            var t = this.data.page + 1;
            this.setData({
                page: t
            }), this.data.getStoreInfo();
        }
    },
    onShareAppMessage: function() {},
    getStoreInfo: function() {
        var a = this, o = t.getNetAddresss("plugin.store-cashier.frontend.store.goods.get-goods-by-kwd");
        t._postNetWork({
            url: o,
            data: {
                store_id: a.data.store_id,
                kwd: this.data.inpvalue,
                page: this.data.page
            },
            success: function(t) {
                var o = t.data;
                console.log(o), 1 == o.result ? a.setData({
                    goods_data: o.data.data,
                    current_page: o.data.current_page,
                    last_page: o.data.last_page
                }) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    tapPush: function(a) {
        var o = t.getNetAddresss("plugin.nearby-store-goods.frontend.controllers.goods.index");
        t._postNetWork({
            url: o,
            data: a,
            success: function(t) {
                var a = t.data;
                console.log(a), 1 == a.result ? wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500,
                    success: function() {
                        wx.navigateBack({
                            delta: 1
                        });
                    }
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});